
import pygame
import random
import math
h = random.randint(-10,10)
v = random.randint(-10,10)

 
# Initialize the game engine
pygame.init()
 
# Define the colors we will use in RGB format
black = [  0,  0,  0]
white = [255,255,255]
blue =  [  0,  0,255]
green = [  0,255,  0]
red =   [255,  0,  0]
 
pi=3.141592653
 
# Set the height and width of the screen
size=[400,500]
screen=pygame.display.set_mode(size)
 
pygame.display.set_caption("Amy Beaumont is a stupid derp-head.")

s = random.randint(1,10)
a = 200 # Horizontal start
b = 250 # Vertical start
 
#Loop until the user clicks the close button.
done=False
clock = pygame.time.Clock()



theta = random.random() * 2 * math.pi
h = math.cos(theta)
v = math.sin(theta)
 
while done==False:
 
    # This limits the while loop to a max of 10 times per second.
    # Leave this out and we will use all CPU we can.
    clock.tick(10)
     
    for event in pygame.event.get(): # User did something
        if event.type == pygame.QUIT: # If user clicked close
            done=True # Flag that we are done so we exit this loop
 
    # All drawing code happens after the for loop and but
    # inside the main while done==False loop.
     
    # Clear the screen and set the screen background
    screen.fill(white)
    
    pygame.draw.circle(screen, red, [int(a),int(b)], 10)
    a = a + h*s
    b = b + v*s
    
    if a >= 390 or a <= 10: #Left/right bounce
      h = -h
      s = random.randint(1,10)
    else:
      h = h
    if b >= 490 or b <= 10: #Top/bottom bounce
      v = -v
      s = random.randint(1,10)
    else:
      v = v 
     
    # Go ahead and update the screen with what we've drawn.
    # This MUST happen after all the other drawing commands.
    pygame.display.flip()
 
# Be IDLE friendly
pygame.quit ()
